package adapter;

import java.util.ArrayList;

import model.PictureInfo;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.fedorvlasov.lazylist.ImageLoader;

import csf.getmoney.R;

public class PictureDetailAdapter extends BaseAdapter {
	Context context;
	ArrayList<PictureInfo> photos;
	LayoutInflater inflater;

	ImageLoader imageLoader;

	public PictureDetailAdapter(Context context, ArrayList<PictureInfo> photos) {
		this.context = context;
		this.photos = photos;
		inflater = ((Activity) context).getLayoutInflater();

		imageLoader = new ImageLoader(context);
		// src
		imageLoader.setType(1);
	}

	@Override
	public int getCount() {
		return photos.size();
	}

	@Override
	public PictureInfo getItem(int position) {
		return photos.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.image_detail, parent, false);
		}
		ImageView image = (ImageView) convertView.findViewById(R.id.iv);
		imageLoader.DisplayImage(getItem(position).getSourceUrl(), image);

		return convertView;
	}

}
